package kotori和气球;

import java.util.Scanner;

public class Main {
    static int MOD = 109;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long m = in.nextLong();
        long res = n;
        for (int i = 0; i < m - 1; i++) {
            res = res * (n - 1) % MOD;
        }
        System.out.println(res);
    }
}
